package org.example.ychdp.service;

import org.example.ychdp.dao.AdminDao;
import org.example.ychdp.entity.Admin;
import org.example.ychdp.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminService {

    @Autowired
    private AdminDao adminDao;

    public Admin selectByPrimaryKey(Integer adminId) {
        return adminDao.selectByPrimaryKey(adminId);
    }

    public Admin selectAdminByName(Admin admin) {
        Admin user1 = adminDao.selectAdminByName(admin.getAdminusername());
        if (user1!=null && user1.getAdminpassword().equals(admin.getAdminpassword())) {
            return user1;
        }
        return adminDao.selectAdminByName(admin.getAdminusername());
    }

    public int updateAdmin(Admin admin) {
        return adminDao.updateByPrimaryKey(admin);
    }
}
